package com.atcc.demo.common;

import java.io.Serializable;
import java.sql.Timestamp;
/**
 * 
 * 
 * @author Administrator
 *     定义restful 统一返回结果
 * @param <T>
 */

public class CommonResult<T> implements Serializable{
	/**
	 *   序列码
	 */
	private static final long serialVersionUID = -2136968402026063364L;

	
	/**
	 *  是否成功
	 * */
	private boolean success = false;
	
	/**
	  返回的信息
	 * 
	 */
    private String message;
    /**
     * 
             * 返回数据
     */
    private T data;
    
    /**
     * 
     * 错误代码
     */
    private String code;
    
    /**
     *  服务器当前时间（添加该字段的原因是便于查找定位请求时间，因为实际开发过程中服务器时间可能跟本地时间不一致，加上这个时间戳便于日后定位）
     */
    
    private Timestamp currentTime;
    
    /**
     * 开发阶段打印异常堆栈信息
     */
    
    private String stackTrace;
    
    public CommonResult() {
    	
    	currentTime = new Timestamp(System.currentTimeMillis());
    }
    
    
    /**
     *  是否成功。返回信息
     * */
    public CommonResult(boolean success,String message) {
    	
    	this.success = success;
    	this.message = message;
    	
    }
    
    /**
     * 
             * 是否成功 
     */
    public CommonResult(boolean success) {
    	
    	this.success = success;
    }
    
    /**
     * 
     * 错误码（成功）和错误（成功）信息
     */
    public CommonResult(String code,String message)
    {
    	this.code = code;
    	this.message = message;
    }
    
    /**
     * 
     *  是否成功，返回信息和数据
     */
    public CommonResult(boolean success,String message,T data) {
    	
    	this.success = success;
    	this.message = message;
    	this.data = data;
    }
    
    public boolean isSuccess() {
    	
    	return success;
    }


	public String getMessage() {
		return message;
	}


	public void setMessage(String message) {
		this.message = message;
	}


	public T getData() {
		return data;
	}


	public void setData(T data) {
		this.data = data;
	}


	public String getCode() {
		return code;
	}


	public void setCode(String code) {
		this.code = code;
	}


	public Timestamp getCurrentTime() {
		return currentTime;
	}


	public void setCurrentTime(Timestamp currentTime) {
		this.currentTime = currentTime;
	}


	public String getStackTrace() {
		return stackTrace;
	}


	public void setStackTrace(String stackTrace) {
		this.stackTrace = stackTrace;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}


	public void setSuccess(boolean success) {
		this.success = success;
	}
    
    
}
